package team.future.joke.service.impl;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;
import static org.springframework.data.mongodb.core.query.Update.update;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import team.future.joke.dao.BaseMongoDao;
import team.future.joke.entity.JokeCollector;
import team.future.joke.service.JokeCollectorService;

/**
 * Title: jokeCollectorServiceImpl.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月2日 上午11:05:29 <br>
 * @author futurezhu
*/
@Service("jokeCollectorService")
public class JokeCollectorServiceImpl implements JokeCollectorService {

	@Autowired
	private BaseMongoDao<JokeCollector> JokeCollectorDao;

	public JokeCollector getJokeCollector(String webName) {
		return JokeCollectorDao.getObject(query(where("webName").is(webName)));
	}

	public void insertJokeCollector(JokeCollector jc) {
		JokeCollectorDao.insertObject(jc);
	}

	public void updateJokeCollector(JokeCollector jc) {
		JokeCollectorDao.updateObject(query(where("webName").is(jc.getWebName())), update("pageSize", jc.getPageSize()));
	}

}
